;;; packages - package definitions for GNU Guix
;;; Copyright (C) 2016, 2017 ng0
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU Affero General Public License as
;;; published by the Free Software Foundation, either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU Affero General Public License for more details.
;;;
;;; You should have received a copy of the GNU Affero General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(define-module (ng0 packages messaging)
  #:use-module (guix packages)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system python)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages lua)
  #:use-module (gnu packages messaging)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages python)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages libffi))

(define-public hyperbit
  (let ((revision "1")
        (commit "8b7a7d3044e4d93ed2813efeb9fe5b13a1a58ced"))
    (package
      (name "hyperbit")
      (version (string-append "0.0.0" "-"
                              revision "." (string-take commit 7)))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "https://github.com/jakobvarmose/hyperbit")
                      (commit commit)))
                (file-name (string-append name "-" version "-checkout"))
                (sha256
                 (base32
                  "1ccs4lhcrx8cmk7lgyrjb1h8lzh7klxlf0k0kq591jkhijacd30r"))))
      (build-system python-build-system)
      (propagated-inputs
       `(("python" ,python)
         ("qtbase" ,qtbase)
         ("python-pyqt" ,python-pyqt)
         ("openssl" ,openssl)
         ("python-cryptography" ,python-cryptography)
         ("python-pysocks" ,python-pysocks)
         ("python-appdirs" ,python-appdirs)
         ("libffi" ,libffi)
         ("python-quamash" ,python-quamash)))
      (synopsis "Alternate client for the Bitmessage network")
      (description
       "HyperBit is an alternate client for the Bitmessage
network.  This is a very early release and should mainly be used
for testing.  If you have any questions or feature requests
please join the hyperbit channel (BM-2cUXYTknxwZgp47DKayzKwNfipQRQCmb2m).
The current version only supports channels, no person-to-person
messages yet.")
      (home-page "https://github.com/jakobvarmose/hyperbit")
      (license license:expat))))

(define-public python-pysocks
  (package
    (name "python-pysocks")
    (version "1.5.7")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "PySocks" version))
       (sha256
        (base32
         "124bydbcspzhkb6ynckvgqra1b79rh5mrq98kbyyd202n6a7c775"))))
    (build-system python-build-system)
    (arguments
     `(#:tests? #f)) ; Tests are optional and use a prebuilt mocks
    (home-page "https://github.com/Anorov/PySocks")
    (synopsis
     "Python SOCKS client module")
    (description
     "Semi-actively maintained SocksiPy fork which contains many
improvements to the original.")
    (license license:bsd-3)))

(define-public python-quamash
(package
  (name "python-quamash")
  (version "0.5.5")
  (source
    (origin
      (method url-fetch)
      (uri (pypi-uri "Quamash" version ".zip"))
      (sha256
       (base32
        "0hlday9p0wdxkajsfzksghyk901yw8g6yl60ww8mh1fphcfydpg3"))))
  (build-system python-build-system)
  (home-page "https://github.com/harvimt/quamash")
  (synopsis
    "Implementation of the PEP 3156 Event-Loop with Qt.")
  (description
    "Implementation of the PEP 3156 Event-Loop with Qt.")
  (license license:bsd-3)))

;; TODO: port to qt5 ?
(define-public dyskinesia
  (let ((revision "1")
        (commit "e1e0fdf510e3745c6ccc622a5b91f966d9f0c648"))
    (package
      (name "dyskinesia")
      (version (string-append "0.0.4.1-"
                              revision "." (string-take commit 7)))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "http://repo.or.cz/dyskinesia.git")
               (commit commit)))
         (file-name (string-append name "-" version "-checkout"))
         (sha256
          (base32
           "1jb7mlrqhzpw91kg72irgjnci31rcdq8g0sz44rdy2392f8ig22z"))))
      (build-system gnu-build-system)
      (arguments
       `(#:phases
         (modify-phases %standard-phases
           (replace 'configure
             (lambda _
               (system* "qmake"))))))
      (home-page "http://repo.or.cz/dyskinesia.git")
      (synopsis "Qt4 PSYC client")
      (description
       "Dyskinesia is a Qt4 PSYC client.")
      (inputs
       `(("libotr" ,libotr)
         ("openssl" ,openssl)
         ;; ("hamsterdb" ,hamsterdb) ; ???
         ;; ("leveldb" ,leveldb) ; ???
         ("qt-4" ,qt-4)
         ("qtwebkit" ,qtwebkit)
         ("lua" ,lua)))
      (native-inputs
       `(("pkg-config" ,pkg-config)))
      ;; COPYING: do what the fuck you want to public license v2
      (license license:public-domain))))
